//var js_element=document.createElement("script");//这句是创建一个script标签
//js_element.setAttribute("type","text/javascript");//脚本用的是javascript
//js_element.setAttribute("src",sys_context+"/js/ligerUI/js/core/base.js");//script标签中引进b.js文件
//document.getElementsByTagName("head")[0].appendChild(js_element);//把script标签加入到<head></head>中
   
    //用户录入查询、选择
	function userInputField(tdid,object,objectId,objectCode,objectName,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:30%;'/>";
	    //显示Name
	    text+="<input id='"+name+"' name='"+name+"' type='text' value='"+objectName+"' style='border-left:0px;width:60%;' readonly='true'/></span>";
	    //$("#newbody").append(text)
	    document.getElementById(tdid).innerHTML = text;
	    $("#"+code).live("dblclick",function(){  
	    	var url = "url:"+sys_context +"/user/openUserDialog.do";
      	    //ChildIframeDialog("userPage","Search User",url,650,480);
	    	getDG().dialog({content: url,title:'Search User',width: 650,height: 480,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.loginName);
	    				$("#"+name).val(rowData.engName);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){  
	    	var value = $("#"+code).attr("value");
	    	if (value==""){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/user/userInputField/" + value + ".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);
	    		    	  $("#"+name).attr("value",data.name);   
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/user/openUserDialog.do";
		    	      	    	  getDG().dialog({content: url,title:'Search User',width: 650,height: 480,lock: true,max: false,min: false,	
		    	      	    		ok: function(){
		    	      	    			var rowData = this.content.getSelectData();
		    	      	    			if (rowData != null) {
		    	      	    				$("#"+object).val(rowData.id);
		    	      	    				$("#"+code).val(rowData.loginName);
		    	      	    				$("#"+name).val(rowData.engName);
		    	      	    		        return true;
		    	      	    			}
		    	      	        		return false;  			
		    	      	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	      	    	 }).zindex();
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	  	    		  $("#"+name).attr("value",""); 
		    	              }	    	              
		    	          });
	    	          }
	    	        }  
	    		});
	    	}
	    });
	 }
	
	//Multi User选择查询
	function userMultiInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";
  
	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='true' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/><span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/user/openUserMultiDialog.do";
	    	getDG().dialog({content: url,title:'Search Muti User',width: 633,height: 487,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData[0]);
	    				//$("#"+code).val(rowData[1]);
	    				$("#"+code).val(rowData[1]).trigger('change');
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	 }).zindex();
	    });
	 }
	
	//Branch录入查询、选择
	function branchInputField(tdid,object,objectId,objectCode,objectName,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:30%;'/>";
	    //显示Name
	    text+="<input id='"+name+"' name='"+name+"' type='text' value='"+objectName+"' style='border-left:0px;width:60%;' readonly='true'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+code).live("dblclick",function(){
      	    var url = "url:"+sys_context +"/user/openBranchDialog.do";
	    	getDG().dialog({content: url,title:'Search Branch',width: 650,height: 480,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.office);
	    				$("#"+name).val(rowData.engName);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){ 
	    	var value = $("#"+code).attr("value");
	    	if (value=="" || value==null){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/user/branchInputField/" + value + ".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);
	    		    	  $("#"+name).attr("value",data.name);   
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/user/openBranchDialog.do";
		    	      	    	  getDG().dialog({content: url,title:'Search Branch',width: 650,height: 480,lock: true,max: false,min: false,	
		    	      	    		ok: function(){
		    	      	    			var rowData = this.content.getSelectData();
		    	      	    			if (rowData != null) {
		    	      	    				$("#"+object).val(rowData.id);
		    	      	    				$("#"+code).val(rowData.office);
		    	      	    				$("#"+name).val(rowData.engName);
		    	      	    		        return true;
		    	      	    			}
		    	      	        		return false;  			
		    	      	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	      	    	  }).zindex();
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	  	    		  $("#"+name).attr("value",""); 
		    	              }	    	              
		    	          });
	    	          }
	    	        }
	    		});
	    	}
	    });
	 }
	
	//Country录入查询、选择
	function countryInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:80%;'/>";
	     //点击按钮
	    text+="<img src='"+sys_context+"/images/search.gif' style='vertical-align:middle; cursor:pointer;' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/predata/openCountryDialog.do";
	    	getDG().dialog({content: url,title:'Search Country',width: 600,height: 410,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.code);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){ 
	    	var value = $("#"+code).attr("value");
	    	if (value=="" || value==null){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/predata/countryInputField/" + value + ".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/predata/openCountryDialog.do";
		    	      	    	  getDG().dialog({content: url,title:'Search Country',width: 600,height: 410,lock: true,max: false,min: false,	
		    	      	    		ok: function(){
		    	      	    			var rowData = this.content.getSelectData();
		    	      	    			if (rowData != null) {
		    	      	    				$("#"+object).val(rowData.id);
		    	      	    				$("#"+code).val(rowData.code);
		    	      	    		        return true;
		    	      	    			}
		    	      	        		return false;  			
		    	      	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	      	    	  }).zindex();
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	              }	    	              
		    	          });
	    	          }
	    	        }
	    		});
	    	}
	    });
	 }

	//Port录入查询、选择 
	/*
	 * type 港口Type,Air/Ocean
	 */
	function portInputField(tdid,object,objectId,objectCode,objectName,type,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:30%;'/>";
	    //显示Name
	    text+="<input id='"+name+"' name='"+name+"' type='text' value='"+objectName+"' style='border-left:0px;width:60%;' readonly='true'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    $("#"+code).live("dblclick",function(){  
      	   var url = "url:"+sys_context +"/port/openPortDialog/"+type+".do";
	       getDG().dialog({content: url,title:'Search Port',width: 650,height: 480,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.code);
	    				$("#"+name).val(rowData.name);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	 }).zindex();
	    });
	    $("#"+code).live("change",function(){ 
	    	var value = $("#"+code).attr("value");
	    	if (value==""){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/port/portInputField/" + value + "/" + type + ".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true" && data.mutliFlag == "false") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);
	    		    	  $("#"+name).attr("value",data.name);   
	    	          } else  if (data && data.success == "true" && data.mutliFlag == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);
	    		    	  $("#"+name).attr("value",data.name);
	    		    	  var url = "url:"+sys_context +"/port/openPortDialog/"+type+".do";
	    			      getDG().dialog({content: url,title:'Search Port',width: 650,height: 480,lock: true,max: false,min: false,	
	    			    		ok: function(){
	    			    			var rowData = this.content.getSelectData();
	    			    			if (rowData != null) {
	    			    				$("#"+object).val(rowData.id);
	    			    				$("#"+code).val(rowData.code);
	    			    				$("#"+name).val(rowData.name);
	    			    		        return true;
	    			    			}
	    			        		return false;  			
	    			    	    },cancelVal: '关闭',cancel: true,parent:this 
	    			    	 }).zindex();
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/port/openPortDialog/"+type+".do";
		    	       	          getDG().dialog({content: url,title:'Search Port',width: 650,height: 480,lock: true,max: false,min: false,	
		    	       	    		ok: function(){
		    	       	    			var rowData = this.content.getSelectData();
		    	       	    			if (rowData != null) {
		    	       	    				$("#"+object).val(rowData.id);
		    	       	    				$("#"+code).val(rowData.code);
		    	       	    				$("#"+name).val(rowData.name);
		    	       	    		        return true;
		    	       	    			}
		    	       	        		return false;  			
		    	       	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	       	    	 }).zindex();		    	            	  
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	  	    		  $("#"+name).attr("value",""); 
		    	              }	    	              
		    	          });
	    	          }
	    	        } 
	    		});
	    	}
	    });
	 }	
	
	//多个Port选择查询
	function portMultiInputField(tdid,object,objectId,objectCode,type,width){
	    var text="";
	    var code = object+"_code";
	    
	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchField'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='true' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
	    	var url = "";
	    	objectId = $("#"+object).val();
	    	if (objectId=="" || objectId==null){
	    		url = "url:"+sys_context +"/port/openPortMultiDialog/"+type+"/0.do";
	    	} else {
	    		url = "url:"+sys_context +"/port/openPortMultiDialog/"+type+"/"+objectId+".do";
	    	}	
		    getDG().dialog({content: url,title:'Port List',width: 500,height: 355,lock: true,max: false,min: false,	
		    		ok: function(){
		    			var rowData = this.content.getSelectData();
		    			if (rowData != null) {
		    				$("#"+object).val(rowData[0]);
		    				$("#"+code).val(rowData[1]);
		    		        return true;
		    			}
		        		return false;  			
		    	    },cancelVal: '关闭',cancel: true,parent:this 
		    }).zindex();
	    });
	 }
	
	//财务公司录入查询、选择
	function financeCompanyInputField(tdid,object,objectId,objectCode,objectName,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:30%;'/>";
	    //显示Name
	    text+="<input id='"+name+"' name='"+name+"' type='text' value='"+objectName+"' style='border-left:0px;width:60%;' readonly='true'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+code).live("dblclick",function(){
      	    var url = "url:"+sys_context +"/currency/openFinanceCompanyDialog.do";
	    	getDG().dialog({content: url,title:'Search Finance Company',width: 650,height: 480,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.code);
	    				$("#"+name).val(rowData.engName);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){ 
	    	var value = $("#"+code).attr("value");
	    	if (value=="" || value==null){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/currency/financeCompanyInputField/" + value + ".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);
	    		    	  $("#"+name).attr("value",data.name);   
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/currency/openFinanceCompanyDialog.do";
		    	      	    	  getDG().dialog({content: url,title:'Search Finance Company',width: 650,height: 480,lock: true,max: false,min: false,	
		    	      	    		ok: function(){
		    	      	    			var rowData = this.content.getSelectData();
		    	      	    			if (rowData != null) {
		    	      	    				$("#"+object).val(rowData.id);
		    	      	    				$("#"+code).val(rowData.code);
		    	      	    				$("#"+name).val(rowData.localName);
		    	      	    		        return true;
		    	      	    			}
		    	      	        		return false;  			
		    	      	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	      	    	}).zindex();
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	  	    		  $("#"+name).attr("value",""); 
		    	              }	    	              
		    	          });
	    	          }
	    	        }
	    		});
	    	}
	    });
	 }
	
	/*Company录入查询、选择
	 * type 标示Company的默认类型选择,如CARRIER=CompanyTypeEnum.CARRIER或者'CUSTOMER,CARRIER'多个类型选择
	 *      否则为null则可以选择所有的
	 * disable 是否可以选择其他的公司类型,true|| false
	*/
	function companyInputField(tdid,object,objectId,objectCode,objectName,type,disable,width){
	    var text="";	
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:30%;'/>";
	    //显示Name
	    text+="<input id='"+name+"' name='"+name+"' type='text' value='"+objectName+"' style='border-left:0px;width:60%;' readonly='true'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+code).live("dblclick",function(){
      	    var url = "url:"+sys_context +"/companyProfile/openCompanyDialog/"+type+"/"+disable+".do";
	    	getDG().dialog({content: url,title:'Search Company',width: 650,height: 480,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				//$("#"+code).val(rowData.code);
	    				$("#"+name).val(rowData.engName);
	    				$("#"+code).val(rowData.code).trigger('change');
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){ 
	    	var value = $("#"+code).attr("value");
	    	if (value=="" || value==null){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/companyProfile/companyInputField/" + value + "/" + type +".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);
	    		    	  $("#"+name).attr("value",data.name);   
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/companyProfile/openCompanyDialog/"+type+"/"+disable+".do";
		    	      	    	  getDG().dialog({content: url,title:'Search Company',width: 650,height: 480,lock: true,max: false,min: false,	
		    	      	    		ok: function(){
		    	      	    			var rowData = this.content.getSelectData();
		    	      	    			if (rowData != null) {
		    	      	    				$("#"+object).val(rowData.id);
		    	      	    				$("#"+code).val(rowData.code);
		    	      	    				$("#"+name).val(rowData.engName);
		    	      	    		        return true;
		    	      	    			}
		    	      	        		return false;  			
		    	      	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	      	    	}).zindex();
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	  	    		  $("#"+name).attr("value",""); 
		    	              }	    	              
		    	          });
	    	          }
	    	        }
	    		});
	    	}
	    });
	 }
	
	//Company Lane选择查询
	function companyLaneInputField(tdid,object,objectId,objectCode,carrier,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:80%;'/>";
	    text+="<input id='"+name+"' name='"+name+"' value='' type='hidden' />";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){   
	        var carrierId = $("#"+carrier).val();  	
		    if (carrierId==""){
		    	alert("请先选择Carrier");
		    	return;
		    }

      	    var url = "url:"+sys_context +"/companyProfile/openCompanyLaneDialog/"+carrierId+".do";
	    	getDG().dialog({content: url,title:'Search Company Lane',width: 450,height: 410,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.code);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){ 
	    	var carrierId = $("#"+carrier).val();  	
		    if (carrierId==""){
		    	alert("请先选择Carrier");
		    	return;
		    }
	    	var value = $("#"+code).attr("value");
	    	if (value=="" || value==null){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/companyProfile/companyLaneInputField/" + value + "/" + carrierId +".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  $("#"+code).attr("value",data.code);  
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/companyProfile/openCompanyLaneDialog/"+carrierId+".do";
		    	      	    	  getDG().dialog({content: url,title:'Search Company Lane',width: 450,height: 410,lock: true,max: false,min: false,	
		    	      	    		ok: function(){
		    	      	    			var rowData = this.content.getSelectData();
		    	      	    			if (rowData != null) {
		    	      	    				$("#"+object).val(rowData.id);
		    	      	    				$("#"+code).val(rowData.code);
		    	      	    		        return true;
		    	      	    			}
		    	      	        		return false;  			
		    	      	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	      	    	 }).zindex();
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	              }	    	              
		    	          });
	    	          }
	    	        }
	    		});
	    	}
	    });
	 }
	
	//Industry选择查询
	function industryInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/accountprofile/openIndustryDialog.do";
	    	getDG().dialog({content: url,title:'Search Industry',width: 600,height: 400,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.engName);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Vessel选择查询
	function vesselInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/vessel/openVesselDialog.do";
	    	getDG().dialog({content: url,title:'Search Vessel',width: 600,height: 415,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.engname);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });

	    $("#"+code).live("change",function(){  
	    	var value = $("#"+code).attr("value");
	    	if (value==""){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    	}
	    });
	 }
	
	//Sales Account录入查询、选择
	function salesAccountInputField(tdid,object,objectId,objectCode,objectName,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    text+="<input id='"+object+"Json' name='"+object+"Json' value='' type='hidden' />"
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' style='width:30%;'/>";
	    //显示Name
	    text+="<input id='"+name+"' name='"+name+"' type='text' value='"+objectName+"' style='border-left:0px;width:60%;' readonly='true'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+code).live("dblclick",function(){
      	    var url = "url:"+sys_context +"/predata/openSalesAccountDialog.do";
	    	getDG().dialog({content: url,title:'Search Account',width: 640,height: 450,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				//$("#"+code).val(rowData.name);
	    				$("#"+name).val(rowData.email);
	    				$("#"+object+"Json").val(JSON.stringify(rowData));
	    				$("#"+code).val(rowData.name).trigger('change');
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){ 
	    	var value = $("#"+code).attr("value");
	    	if (value=="" || value==null){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    	} else {
	    		$.ajax({
	    			type : "POST",
	    			url : sys_context+"/predata/salesAccountInputField/NAME/" + value + ".do",
	    			dataType : 'json',   
	    	        success : function(data) { 
	    	          if (data && data.success == "true") {   	    	      
	    	        	  $("#"+object).attr("value",data.id);
	    		    	  //$("#"+code).attr("value",data.code);
	    		    	  $("#"+name).attr("value",data.name);
	    		    	  $("#"+object+"Json").val(data.office);
	    		    	  $("#"+code).val(rowData.name).trigger('change');
	    	          } else if (data && data.success == "false") { 
	    	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/predata/openSalesAccountDialog.do";
		    	      	    	  getDG().dialog({content: url,title:'Search Account',width: 640,height: 450,lock: true,max: false,min: false,	
		    	      	    		ok: function(){
		    	      	    			var rowData = this.content.getSelectData();
		    	      	    			if (rowData != null) {
		    	      	    				$("#"+object).val(rowData.id);
		    	      	    				//$("#"+code).val(rowData.name);
		    	      	    				$("#"+name).val(rowData.email);
		    	      	    				$("#"+object+"Json").val(JSON.stringify(rowData));
		    	      	    				$("#"+code).val(rowData.name).trigger('change');
		    	      	    		        return true;
		    	      	    			}
		    	      	        		return false;  			
		    	      	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	      	    	}).zindex();
		    	              }	else {
		    	            	  $("#"+object).attr("value","");
		    	  	    		  $("#"+code).attr("value","");
		    	  	    		  $("#"+name).attr("value",""); 
		    	              }	    	              
		    	          });
	    	          }
	    	        }
	    		});
	    	}
	    });
	 }
	
	//Service Required选择查询
	function serviceRequiredInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<img src='"+sys_context+"/images/search.gif' style='vertical-align:middle; cursor:pointer;' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/accountprofile/openServiceRequiredDialog.do";
	    	getDG().dialog({content: url,title:'Search Service Required',width: 500,height: 400,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData[0]);
	    				$("#"+code).val(rowData[1]);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Competitor选择查询
	function competitorInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
        	var url = "url:"+sys_context +"/accountprofile/openCompetitorDialog.do";
  	    	getDG().dialog({content: url,title:'Select Competitor',width: 553,height: 457,lock: true,max: false,min: false,	
  	    		ok: function(){
  	    			var rowData = this.content.getSelectData();
  	    			if (rowData != null) {
  	    				$("#"+object).val(rowData.id);
  	    				$("#"+code).val(rowData.engName);
  	    		        return true;
  	    			}
  	        		return false;  			
  	    	    },cancelVal: '关闭',cancel: true,parent:this 
  	    	}).zindex();
	    });
	 }
	
	//Service Type选择查询
	function serviceTypeInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchField'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/predata/openServiceTypeDialog/NULL.do";
	    	getDG().dialog({content: url,title:'Select Service Type',width: 553,height: 457,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.desc);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Service Type多选查询
	function serviceTypeMultiInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchField'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/predata/openServiceTypeDialog/Multi.do";
	    	getDG().dialog({content: url,title:'Select Service Type',width: 553,height: 457,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData[0]);
	    				$("#"+code).val(rowData[1]);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	function serviceTypeComboBox(tdid,object,value,width){
		$.ajax({
			type : "POST",
			url : sys_context+"/predata/serviceTypeComboBox.do",
			dataType: 'json',   
	        success : function(data) { 
	           if (data && data.success == "true") {
		    	  var jsondata=eval(data.items); // convert json data
		    	  $("#"+tdid).append("<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>" +
		    			  "<select class='searchString' id="+object+" name="+object+"></select></span>");
		    	  
	        	  $.each(jsondata, function(i,item){
		    	      if(item.id==value){
	        			  $("#"+object).append('<option value='+item.id+' selected>'+item.desc+'</option>');		  				 
	  				  } else if(item.desc==value){
	        			  $("#"+object).append('<option value='+item.id+' selected>'+item.desc+'</option>');		  				 
	  				  } else{
	  					  $("#"+object).append('<option value='+item.id+'>'+item.desc+'</option>');
	  				  }	
		    	  });
	           }
	        }
		});	    
	 }
	
	//Currency录入查询、选择
	function currencyComboBox(tdid,object,value,width,flag){
		//flag true为id vlue 否则为code
	    $.ajax({
			type : "POST",
			url : sys_context+"/predata/currencyComboBox.do",
			dataType: 'json',   
	        success : function(data) { 
	           if (data && data.success == "true") {
		    	  var jsondata=eval(data.items); // convert json data
		    	  $("#"+tdid).append("<select class='searchString' id="+object+" name="+object+" style='width:"+width+"'></select>");
		    	  
	        	  $.each(jsondata, function(i,item){
	        		  if (flag){
	        			  if(item.id==value){
		        			  $("#"+object).append('<option value='+item.id+' selected>'+item.code+'</option>');		  				 
		  				  } else{
		  					  $("#"+object).append('<option value='+item.id+'>'+item.code+'</option>');
		  				  }		 
	        		  } else {
	        			  if(item.code==value){
		  					  $("#"+object).append('<option value='+item.code+' selected>'+item.code+'</option>');
		  				  } else{
		  					  $("#"+object).append('<option value='+item.code+'>'+item.code+'</option>');
		  				  }		 
	        		  }	        		     	     
		    	  });
	           }
	        }
		});
	 }
	
	//Unit录入查询、选择
	function unitComboBox(tdid,object,value,type,width){	    	    
	    $.ajax({
			type : "POST",
			url : sys_context+"/predata/unitComboBox/"+type+".do",
			dataType: 'json',   
	        success : function(data) { 
	           if (data && data.success == "true") {
		    	  var jsondata=eval(data.items); // convert json data
		    	  $("#"+tdid).append("<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>" +
		    			  "<select class='searchString' id="+object+" name="+object+"></select></span>");
		    	  
	        	  $.each(jsondata, function(i,item){
		    	      if(item.id==value){
	        			  $("#"+object).append('<option value='+item.id+' selected>'+item.code+'</option>');		  				 
	  				  } else if(item.code==value){
	        			  $("#"+object).append('<option value='+item.id+' selected>'+item.code+'</option>');		  				 
	  				  } else{
	  					  $("#"+object).append('<option value='+item.id+'>'+item.code+'</option>');
	  				  }	
		    	  });
	           }
	        }
		});	    
	 }
	
	/*Trade Lane录入查询、选择  
	 * flag为1时表示下拉框显示的id
	 * flag为2时表示下拉框显示的code
	 * flag为3时值为code，下拉框显示也是code
	 * flag为4时值为name，下拉框显示也是name
	 * isNull为true表示默认设置一个空值，false去掉
	 */	
	function tradeLaneComboBox(tdid,object,value,width,flag,isNull){
	    $.ajax({
			type : "POST",
			url : sys_context+"/predata/tradeLaneComboBox.do",
			dataType: 'json', 
	        success : function(data) { 
	           if (data && data.success == "true") {
		    	  var jsondata=eval(data.items); // convert json data
		    	  if (isNull){
		    	       $("#"+tdid).append("<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>" +
		    	  		   "<select class='searchString' id="+object+" name="+object+"><option value=''></option></select></span>");
		    	  } else {
		    	       $("#"+tdid).append("<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>" +
			    	  	   "<select class='searchString' id="+object+" name="+object+"></select></span>");
		    	  }
		    	  
	        	  $.each(jsondata, function(i,item){
	        		  if (flag==1){
	        			  if(item.id==value){
		        			  $("#"+object).append('<option value='+item.id+' selected>'+item.name+'</option>');		  				 
		  				  } else{
		  					  $("#"+object).append('<option value='+item.id+'>'+item.name+'</option>');
		  				  }	  
	        		  } else if (flag==2){
                          if(item.id==value){
		        			  $("#"+object).append('<option value='+item.id+' selected>'+item.code+'</option>');		  				 
		  				  } else{
		  					  $("#"+object).append('<option value='+item.id+'>'+item.code+'</option>');
		  				  }	
	        			  
	        		  } else if (flag==3){
	        			  if(item.id==value){
		        			  $("#"+object).append('<option value='+item.code+' selected>'+item.code+'</option>');		  				 		  				 
		  				  } else{
		  					  $("#"+object).append('<option value='+item.code+'>'+item.code+'</option>');
		  				  }	  
	        		  }	else if (flag==4){
	        			  if(item.name==value){
		        			  $("#"+object).append('<option value='+item.name+' selected>'+item.name+'</option>');		  				 		  				 
		  				  } else{
		  					  $("#"+object).append('<option value='+item.name+'>'+item.name+'</option>');
		  				  }	  
	        		  }        		  
		    	  });
	        	  //$("#regional").append("<option value='0'>请选择</option>");   //为Select插入一个Option(第一个位置) 			
	           }
	        }
		});	    
	    //$("#"+object).ligerComboBox({resize:false,selectBoxWidth: width,labelWidth:width}); 
	 }
	
	//Trade Lane选择查询
	function tradeLaneInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<img src='"+sys_context+"/images/search.gif' style='vertical-align:middle; cursor:pointer;' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/predata/openTradeLaneDialog.do";
	    	getDG().dialog({content: url,title:'Search Trade Lane',width: 500,height: 400,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData[0]);
	    				$("#"+code).val(rowData[1]);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Trade Term录入查询、选择
	function tradeTermComboBox(tdid,object,value,width){
	    $.ajax({
			type : "POST",
			url : sys_context+"/predata/tradeTermComboBox.do",
			dataType: 'json',   
	        success : function(data) { 
	           if (data && data.success == "true") {
		    	  var jsondata=eval(data.items); // convert json data
		    	  $("#"+tdid).append("<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>" +
		    			  "<select class='searchString' id="+object+" name="+object+" ></select></span>");
		    	  
	        	  $.each(jsondata, function(i,item){
	        		  if(item.id==value){
	        			  $("#"+object).append('<option value='+item.id+' selected>'+item.code+'</option>');		  				 
	  				  } else if(item.code==value){
	        			  $("#"+object).append('<option value='+item.id+' selected>'+item.code+'</option>');		  				 
	  				  } else{
	  					  $("#"+object).append('<option value='+item.id+'>'+item.code+'</option>');
	  				  }	
		    	  });
	           }
	        }
		});	    
	    $("#"+object).ligerComboBox({resize:false,selectBoxWidth: 100,labelWidth:100}); 
	    //$("#"+object).find("option:contains("+value+")").attr("selected", "selected"); 
	 }
	
	//Account Profile Contact选择查询
	function accountProfileContactInputField(tdid,object,objectId,objectCode,apId,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/><span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/accountprofile/openContactDialog/"+apId+".do";
	    	getDG().dialog({content: url,title:'Select Contact',width: 500,height: 300,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.contactName);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Consignee选择查询
	function consigneeInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var width1 = parseInt(width)*0.9;
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' style='width:80%;' />";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
      	    var url = "url:"+sys_context +"/consignee/openConsigneeDialog.do";
	    	getDG().dialog({content: url,title:'Select Consignee',width: 600,height: 400,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.engName);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Contract录入查询、选择
	function contractInputField(tdid,object,objectId,contactNo,carrierId,carrierCode,carrierName,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";
	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    text+="<input id='"+object+"Code' name='"+object+"Code' value='"+contactNo+"' type='hidden' class='searchString'/>";
	    text+="<input id='"+object+"CarrierId' name='"+object+"CarrierId' value='"+carrierId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+carrierCode+"' style='width:30%;'/>";
	    //显示Name
	    text+="<input id='"+name+"' name='"+name+"' type='text' value='"+carrierName+"' style='border-left:0px;width:60%;' readonly='true'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+code).live("dblclick",function(){
      	    var url = "url:"+sys_context +"/contract/openContractDialog.do";
	    	getDG().dialog({content: url,title:'Select Contract',width: 600,height: 400,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+object+"Code").val(rowData.contractNo);
	    				//$("#"+code).val(rowData["company.code"]);
	    				$("#"+object+"CarrierId").val(rowData["company.id"]);
	    				$("#"+name).val(rowData["company.engName"]);
	    				$("#"+code).val(rowData["company.code"]).trigger('change');
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	    $("#"+code).live("change",function(){  
	    	var value = $("#"+code).attr("value");
	    	if (value==""){
	    		$("#"+object).attr("value","");
	    		$("#"+code).attr("value","");
	    		$("#"+name).attr("value","");
	    		$("#"+object+"Code").attr("value","");
	    		$("#"+object+"CarrierId").attr("value","");
	    	}
	    });
	 }
	
	//POCInfo Mother录入查询、选择
	function POCInfoMotherInputField(tdid,object,motherPOCInfoId,objectId,objectCode,carrier,width){
	    var text="";
	    var code = object+"_code";
	    var name = object+"_name";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    text+="<input id='"+object+"Id' name='"+object+"Id' value='"+motherPOCInfoId+"' type='hidden' />"
	    text+="<input id='"+object+"Json' name='"+object+"Json' value='' type='hidden' />"
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/>";
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
	    	var carrierId = $("#"+carrier).val();  	
	    	if (carrierId==""){
		    	alert("请先选择Carrier");
		    	return;
		    }
      	    var url = "url:"+sys_context +"/sailingSchedule/openPOCInfoMotherDialog/"+carrierId+".do";
	    	getDG().dialog({content: url,title:'Select POCInfo',width: 800,height: 500,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData['sailingSchedule.companyLane.id']);
	    				$("#"+object+"Id").val(rowData.id)
	    				$("#"+object+"Json").val(JSON.stringify(rowData));
	    				$("#"+code).val(rowData['sailingSchedule.companyLane.code']).trigger('change');
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//POCInfo 录入查询、选择
	function POCInfoInputField(tdid,object,objectId,objectCode,carrier,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    text+="<input id='"+object+"Json' name='"+object+"Json' value='' type='hidden' />"
	    //显示Code
	    text+="<input id='"+code+"' name='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
	    	var carrierId = $("#"+carrier).val();
	    	if (carrierId==""){
		    	alert("请先选择Carrier");
		    	return;
		    }
      	    var url = "url:"+sys_context +"/sailingSchedule/openPOCInfoDialog/"+carrierId+".do";
	    	getDG().dialog({content: url,title:'Select POCInfo',width: 800,height: 500,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData['preCarrige.id']);
	    				//$("#"+code).val(rowData.etd);
	    				$("#"+object+"Json").val(JSON.stringify(rowData));
	    				$("#"+code).val(rowData.preEtd).trigger('change');
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Contract Commodity选择查询
	function commodityInputField(tdid,object,objectId,objectCode,contract,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<img src='"+sys_context+"/images/search.gif' style='vertical-align:middle; cursor:pointer;' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
	    	var contractId = $("#"+contract).val();  	
		    if (contractId==""){
		    	alert("请先选择Contract");
		    	return;
		    }

      	    var url = "url:"+sys_context +"/contract/openCommodityDialog/"+contractId+".do";
	    	getDG().dialog({content: url,title:'Select Commodity',width: 553,height: 467,lock: true,max: false,min: false,	
	    		ok: function(){
	    			var rowData = this.content.getSelectData();
	    			if (rowData != null) {
	    				$("#"+object).val(rowData.id);
	    				$("#"+code).val(rowData.item);
	    		        return true;
	    			}
	        		return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	}).zindex();
	    });
	 }
	
	//Suppliers配合业务类型
	function cooperateInputField(tdid,object,objectId,objectCode,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<img src='"+sys_context+"/images/search.gif' style='vertical-align:middle; cursor:pointer;' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
	    	getDG().dialog({
	    		title:'Select Service Type',
	    		width : 480,
	    		height : 300,
	    		content: 'url:' + sys_context+'/predata/openCooperateTypeDialog.do?cooprateTypes='+objectId,
	    		lock : true,
	    		max : true,
	    		min : true,
	    		ok: function(){
	    			
	    			var selCooperate = this.content.getSelectedCooperate();
	    			var josonSel = JSON.stringify(selCooperate);
	    			
	    			if(josonSel!=null){
	    				var inoutStr  = "";
	    				$.each(selCooperate,function(i,r){
	    					var cooperateInout = r['INOUT'];
	    					if(inoutStr!=""){
	    						inoutStr = inoutStr + "/";
	    					}
	    					if(cooperateInout=="3"){
	    						inoutStr = inoutStr + r['code']+"-"+"In/"+r['code']+"-"+"Out";
	    					}
	    					if(cooperateInout=="2"){
	    						inoutStr = inoutStr + r['code']+"-"+"Out";
	    					}
	    					if(cooperateInout=="1"){
	    						inoutStr = inoutStr + r['code']+"-"+"In";
	    					}
	    				});
	    				$("#"+code).val(inoutStr);
	    				$("#"+object).val(josonSel);
	    				return true;
	    			}
	    			return false;
	    			
	    	    },
	    	    cancelVal: '关闭',
	    	    cancel: true 
	    	}).zindex();
	    });
	 }
	
	//报价单选择查询
	function quotationInputField(tdid,object,objectId,objectCode,apId,type,width){
	    var text="";
	    var code = object+"_code";

	    //生成ID
	    text="<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>";
	    text+="<input id='"+object+"' name='"+object+"' value='"+objectId+"' type='hidden' class='searchString'/>";
	    //显示Code
	    text+="<input id='"+code+"' type='text' value='"+objectCode+"' readonly='readonly' style='width:80%;'/>";
	    //点击按钮
	    text+="<input type='button' class='btn_query' id='"+object+"Id'/></span>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    
	    $("#"+object+"Id").live("click",function(){
        	var url = "url:"+sys_context +"/salesquotation/openQuotationDialog/"+apId+"/"+type+".do";
  	    	getDG().dialog({content: url,title:'Select Quotation',width: 650,height: 450,lock: true,max: false,min: false,	
  	    		ok: function(){
  	    			var rowData = this.content.getSelectData();
  	    			if (rowData != null) {
  	    				$("#"+object).val(rowData.id);
  	    				//$("#"+code).val(rowData.quotationDate);
  	    				$("#"+code).val(rowData.quotationDate).trigger('change');
  	    		        return true;
  	    			}
  	        		return false;  			
  	    	    },cancelVal: '关闭',cancel: true,parent:this 
  	    	}).zindex();
	    });
	 }
	
	/*资产的基础资料下拉列表
	 * flag true 以name下拉列表值
	 * false 以id为下拉列表值
	 */
	function assetBasedataComboBox(tdid,object,value,typeId,width,flag){
		$.getJSON(sys_context+'/assertBasedata/getBasedatas.do?type='+typeId,
			function(data){
				 $("#"+tdid).append("<span style='width:"+width+"px;'><input type='hidden' class='searchField' value='"+object+"'>" +
		    			  "<select class='searchString' id="+object+" name="+object+"><option value=''></option></select></span>");
		    	  
	        	  $.each(data, function(i,item){
	        		  if(flag){
			    	      if(item.id==value){
		        			  $("#"+object).append('<option value='+item.name+' selected>'+item.name+'</option>');		  				 	  				 
		  				  } else{
		  					  $("#"+object).append('<option value='+item.name+'>'+item.name+'</option>');
		  				  }	
	        		  } else {
			    	      if(item.id==value){
		        			  $("#"+object).append('<option value='+item.id+' selected>'+item.name+'</option>');		  				 	  				 
		  				  } else{
		  					  $("#"+object).append('<option value='+item.id+'>'+item.name+'</option>');
		  				  }	
	        		  }
		    	  });
			}		
		);
	}
	
	//生成DefaultFlagEnum的CheckBoxs
	function checkBoxsField(tdid,object,list,width){
		var text="";
		//生成ID
	    text="<form:checkboxes itemValue='value' itemLabel='label' path="+object+" items="+list+"/>";
	    
	    document.getElementById(tdid).innerHTML=text;
	    $('#'+object+"1").click(function() {
		    if ($(this).prop('checked')) {
		        $('#'+object+"2").prop({
		            checked: false
		        });
		    }
		});
	   $('#'+object+"2").click(function() {
		    if ($(this).prop('checked')) {
		        $('#'+object+"1").prop({
		            checked: false
		        });
		    }
		});
	}
	
	//lierUI grid input carrier
	/*
	 * type 标示Company的默认类型选择,如CARRIER=CompanyTypeEnum.CARRIER或者'CUSTOMER,CARRIER'多个类型选择
	 *      否则为null则可以选择所有的
	 * disable 是否可以选择其他的公司类型,true|| false 
	 */
	function inputCarrier(grid,columnName,value,type,disabled,dblclick){
		if (dblclick){
			var url = "url:"+sys_context +"/companyProfile/openCompanyDialog/"+type+"/"+disabled+".do";
	    	     getDG().dialog({content: url,title:'Search Company',width: 650,height: 480,lock: true,max: false,min: false,	
	    		    ok: function(){
	    			   var rowData = this.content.getSelectData();
	    			   if (rowData != null) {       	    		 
	    				   grid.updateCell(columnName, {id:rowData.id,engName:rowData.engName}, grid.getSelected());
	    				   grid.endEdit();
	    		           return true;
	    			   }
	        		   return false;  			
	    	    },cancelVal: '关闭',cancel: true,parent:this 
	    	 }).zindex();
		} else {
			$.ajax({
				type : "POST",
				url : sys_context+"/companyProfile/companyInputField/" + value + "/" + type +".do",
				dataType : 'json',   
		        success : function(data) { 
		          if (data && data.success == "true") {  
		        	  grid.updateCell(columnName, {id:data.id,engName:data.name}, grid.getSelected());
					  grid.endEdit();
			          return true; 
		          } else if (data && data.success == "false") { 
	 	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	 var url = "url:"+sys_context +"/companyProfile/openCompanyDialog/"+type+"/"+disabled+".do";
	              	    	     getDG().dialog({content: url,title:'Search Company',width: 650,height: 480,lock: true,max: false,min: false,	
	              	    		    ok: function(){
	              	    			   var rowData = this.content.getSelectData();
	              	    			   if (rowData != null) {       	    		 
	              	    				   grid.updateCell(columnName, {id:rowData.id,engName:rowData.engName}, grid.getSelected());
	              	    				   grid.endEdit();
	              	    		           return true;
	              	    			   }
	              	        		   return false;  			
	              	    	    },cancelVal: '关闭',cancel: true,parent:this 
	              	    	 }).zindex();
	              	    	 return false;
		    	          } else {
		    	        	  grid.updateCell(columnName, {id:'',engName:''}, grid.getSelected());
	 	    				  grid.endEdit();
	 	    		          return true;
		    	          }
	 	        	  });
	 	          }
	 	        }
	 	     }); 
		}		
	}
	
	function inputPort(grid,columnName,value,type,dblclick){
		if (dblclick){
			var url = "url:"+sys_context +"/port/openPortDialog/"+type+".do";
		    getDG().dialog({content: url,title:'Search Port',width: 650,height: 480,lock: true,max: false,min: false,	
		    		ok: function(){
		    			var rowData = this.content.getSelectData();
		    			if (rowData != null) {
		    			   grid.updateCell(columnName, {id:rowData.id,name:rowData.name}, grid.getSelected());
						   grid.endEdit();
					       return true;  
		    			}
		        		return false;  			
		    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	 }).zindex();
		} else {
			$.ajax({
				type : "POST",
				url : sys_context+"/port/portInputField/" + value + "/" + type + ".do",
				dataType : 'json',   
		        success : function(data) {
		           if (data && data.success == "true" && data.mutliFlag == "false") {   	    	      
		        	   grid.updateCell(columnName, {id:data.id,name:data.name}, grid.getSelected());
					   grid.endEdit();
				       return true;    
	  	           } else  if (data && data.success == "true" && data.mutliFlag == "true") {   	    	      
	  	        	   grid.updateCell(columnName, {id:data.id,name:data.name}, grid.getSelected());
					   grid.endEdit();
				       return true;  
	  		    	  var url = "url:"+sys_context +"/port/openPortDialog/"+type+".do";
	  			      getDG().dialog({content: url,title:'Search Port',width: 650,height: 480,lock: true,max: false,min: false,	
	  			    		ok: function(){
	  			    			var rowData = this.content.getSelectData();
	  			    			if (rowData != null) {
	  			    			   grid.updateCell(columnName, {id:rowData.id,name:rowData.name}, grid.getSelected());
	  							   grid.endEdit();
	  						       return true;  
	  			    			}
	  			        		return false;  			
	  			    	    },cancelVal: '关闭',cancel: true,parent:this 
	  			    	 }).zindex();
		          } else if (data && data.success == "false") { 
	 	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/port/openPortDialog/"+type+".do";
		    	          	      getDG().dialog({content: url,title:'Search Port',width: 650,height: 480,lock: true,max: false,min: false,	
		    	          	    		ok: function(){
		    	          	    			var rowData = this.content.getSelectData();
		    	          	    			if (rowData != null) {
		    	          	    				 grid.updateCell(columnName, {id:rowData.id,name:rowData.name}, grid.getSelected());
		    	          	    				 grid.endEdit();
		    	          	    		         return true;
		    	          	    			}
		    	          	        		return false;  			
		    	          	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	          	      }).zindex();
		    	                  return false;
		    	          } else {
		    	        	  grid.updateCell(columnName, {id:'',name:''}, grid.getSelected());
	 	    				  grid.endEdit();
	 	    		          return true;
		    	          }
	 	        	  });
	 	          }
	 	        }
	 	     }); 
	    }
	}
	
	
	function inputCharge(grid,columnName,value,dblclick){
		if (dblclick){
			var url = "url:"+sys_context +"/charge/openChargeDialog.do";
    	      getDG().dialog({content: url,title:'Search Charge',width: 650,height: 380,lock: true,max: false,min: false,	
    	    		ok: function(){
    	    			var rowData = this.content.getSelectData();
    	    			if (rowData != null) {
    	    				grid.updateCell(columnName, {id:rowData.id,code:rowData.code}, grid.getSelected());
    	    				grid.endEdit();
    	    		        return true;
    	    			}
    	        		return false;  			
    	    	    },cancelVal: '关闭',cancel: true,parent:this 
    	    }).zindex();
		} else {
			$.ajax({
				type : "POST",
				url : sys_context+"/charge/chargeInputField/" + value + ".do",
				dataType : 'json',   
		        success : function(data) { 
		          if (data && data.success == "true") {  
		        	  grid.updateCell(columnName, {id:data.id,code:data.code}, grid.getSelected());
					  grid.endEdit();
			          return true; 
		          } else if (data && data.success == "false") { 
	 	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/charge/openChargeDialog.do";
		    	          	      getDG().dialog({content: url,title:'Search Charge',width: 650,height: 380,lock: true,max: false,min: false,	
		    	          	    		ok: function(){
		    	          	    			var rowData = this.content.getSelectData();
		    	          	    			if (rowData != null) {
		    	          	    				grid.updateCell(columnName, {id:rowData.id,code:rowData.code}, grid.getSelected());
		    	          	    				grid.endEdit();
		    	          	    		        return true;
		    	          	    			}
		    	          	        		return false;  			
		    	          	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	          	    }).zindex();
		    	                 return false;
		    	          } else {
		    	        	  grid.updateCell(columnName, {id:'',code:''}, grid.getSelected());
	 	    				  grid.endEdit();
	 	    		          return true;
		    	          }
	 	        	  });
	 	          }
	 	        }
	 	     }); 
		}		
	}
	
	function inputContainer(grid,columnName,value,dblclick){
		if (dblclick){
			var url = "url:"+sys_context +"/predata/openContainerTypeDialog.do";
    	    getDG().dialog({content: url,title:'Search Container Type',width: 650,height: 380,lock: true,max: false,min: false,	
    	    		ok: function(){
    	    			var rowData = this.content.getSelectData();
    	    			if (rowData != null) {
    	    				grid.updateCell(columnName, {id:rowData.id,type:rowData.type,maxWeight:rowData.maxWeight,volumeUnit:rowData.volumeUnit}, grid.getSelected());
    	    				grid.endEdit();
    	    		        return true;
    	    			}
    	        		return false;  			
    	    	    },cancelVal: '关闭',cancel: true,parent:this 
    	    }).zindex();
		} else {
			$.ajax({
				type : "POST",
				url : sys_context+"/predata/containerInputField/" + value + ".do",
				dataType : 'json',   
		        success : function(data) { 
		          if (data && data.success == "true") {  
		        	  grid.updateCell(columnName, {id:data.id,type:data.code,maxWeight:data.maxWeight,volumeUnit:data.volumeUnit}, grid.getSelected());
					  grid.endEdit();
			          return true; 
		          } else if (data && data.success == "false") { 
	 	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/predata/openContainerTypeDialog.do";
		                    	    getDG().dialog({content: url,title:'Search Container Type',width: 650,height: 380,lock: true,max: false,min: false,	
		                    	    		ok: function(){
		                    	    			var rowData = this.content.getSelectData();
		                    	    			if (rowData != null) {
		                    	    				grid.updateCell(columnName, {id:rowData.id,type:rowData.type,maxWeight:rowData.maxWeight,volumeUnit:rowData.volumeUnit}, grid.getSelected());
		                    	    				grid.endEdit();
		                    	    		        return true;
		                    	    			}
		                    	        		return false;  			
		                    	    	    },cancelVal: '关闭',cancel: true,parent:this 
		                    	    }).zindex();
		                            return false;
		    	          } else {
		    	        	  grid.updateCell(columnName, {id:'',type:'',maxWeight:'',volumeUnit:''}, grid.getSelected());
	 	    				  grid.endEdit();
	 	    		          return true;
		    	          }
	 	        	  });
	 	          }
	 	        }
	 	     });
		}		 
	}
	
	function inputCurrency(grid,columnName,value,dblclick){
		if (dblclick){
			var url = "url:"+sys_context +"/currency/searchCurrency.do";
    	      getDG().dialog({content: url,title:'Search Currency',width: 650,height: 380,lock: true,max: false,min: false,	
    	    		ok: function(){
    	    			var rowData = this.content.getSelectData();
    	    			if (rowData != null) {
    	    				grid.updateCell(columnName, {id:rowData.id,code:rowData.code}, grid.getSelected());
    	    				grid.endEdit();
    	    		        return true;
    	    			}
    	        		return false;  			
    	    	    },cancelVal: '关闭',cancel: true,parent:this 
    	    }).zindex();
		} else {
			$.ajax({
				type : "POST",
				url : sys_context+"/currency/currencyInputField/" + value + ".do",
				dataType : 'json',   
		        success : function(data) { 
		          if (data && data.success == "true") {  
		        	  grid.updateCell(columnName, {id:data.id,code:data.code}, grid.getSelected());
					  grid.endEdit();
			          return true; 
		          } else if (data && data.success == "false") { 
	 	        	  $.ligerDialog.confirm('The code you input does not exist, do you want to search?', function (yes){
		    	              if (yes){
		    	            	  var url = "url:"+sys_context +"/currency/searchCurrency.do";
		    	          	      getDG().dialog({content: url,title:'Search Currency',width: 650,height: 380,lock: true,max: false,min: false,	
		    	          	    		ok: function(){
		    	          	    			var rowData = this.content.getSelectData();
		    	          	    			if (rowData != null) {
		    	          	    				grid.updateCell(columnName, {id:rowData.id,code:rowData.code}, grid.getSelected());
		    	          	    				grid.endEdit();
		    	          	    		        return true;
		    	          	    			}
		    	          	        		return false;  			
		    	          	    	    },cancelVal: '关闭',cancel: true,parent:this 
		    	          	    }).zindex();
		    	                 return false;
		    	          } else {
		    	        	  grid.updateCell(columnName, {id:'',code:''}, grid.getSelected());
	 	    				  grid.endEdit();
	 	    		          return true;
		    	          }
	 	        	  });
	 	          }
	 	        }
	 	     }); 
		}		
	}
	
	//js div加载页面	   
	function loadPage(id, url) { 
	    $("#"+id).addClass("loader"); 
	    $("#"+id).append("Loading......"); 
		$.ajax({ 
			type: "get", 
			url: url, 
			cache: false, 
			error: function() {alert('加载页面' + url + '时出错！');}, 
			success: function(msg) { 
			   $("#"+id).empty().append(msg); 
			   $("#"+id).removeClass("loader"); 
		    } 
		}); 
	}
	
	/*
	 * 查找数组中的字符
	 * replace(/\s+/g,"")去空格
	 * replace(/(\[)|(\])/g,"")去掉左[右]
	 */
	function search_Array(arrayOrArgs, SearchFor){		  
		  var arr = new Array();
		  arr = arrayOrArgs.replace(/\s+/g,"").replace(/(\[)|(\])/g,"").split(",");

		  return getKeyByDinner(arr,SearchFor);
	}
	
	function isArray(o) {   
	   return Object.prototype.toString.call(o) === '[object Array]';    
	}  
	
	var getKeyByDinner = function(obj, dinner) {     
		var returnKey = -1;      
		$.each(obj, function(key, info) {        
			if (info == dinner) {           
				returnKey = key;            
				return returnKey;        
			};       
		});      
		return returnKey; 
    }
	
	/*
	 * 让某段代码延时执行
	 * onmouseover=delayRun("setTab(0,0)",500)
     * 其中setTab是一个自定义的函数。如果以后不想让setTab延时执行，则去掉语句中的delayRun相关的代码即可，
     * 改为：onmouseover=setTab(0,0) 就可以了
	 */
	function delayRun(code,time) { 
		var t=setTimeout(code,time); 
	} 
	
	/*
	 * http://james.padolsey.com/javascript/jquery-delay-plugin/
	 * // Change background color of all anchors after 1 second:
        $('a').delay(1000, function(){
           $(this).css({
              background: 'red'
           });
        });
	 */
	$.fn.delay = function(time, callback){  
		// Empty function:  
		jQuery.fx.step.delay = function(){};  
		// Return meaningless animation, (will be added to queue)  
        return this.animate({delay:1}, time, callback);  
    } 

	function validate_phone(phone,type){
		var pattern
		//中国电话验证
		if (type){
	       pattern = /^([0-9]{2,5}-)([0-9]{6,8})+(\\-[0-9]{1,4})?$/;
	       if (!pattern.test(phone)){
	    	   pattern = /^(([0\\+]\\d{2,3}-)?(\\d{2,4})-)(\\d{7,8})(-(\\d{3,}))?/;
	       }	       
		} else {
			pattern = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{3,7})$/;
		    if (!pattern.test(phone)){
		       pattern = /^(([0\\+]\\d{2,3}-)?(\\d{2,4})-)(\\d{7,8})(-(\\d{4,}))?/;

		      /*/^(([0\\+]\\d{2,3}-)?(\\d{2,4})-)(\\d{7,8})(-(\\d{3,}))?/;*/
		    }
		}
       var result = pattern.test(phone);
      
       return result;
    }